<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>list student course</title>
</head>
<body>
<h1>list student course</h1>
<table border="1">
    <tr>
        <th>ID</th>
        <th>STUDENT</th>
        <th>COURSES</th>
    </tr>
    <c:forEach var="student" items="${sessionScope.students}">
        <tr>
            <td>${student.id}</td>
            <td>${student.name}</td>
            <c:if test="${student.courses.size() eq 0}">
                <td>
                    未选课
                </td>
            </c:if>
            <c:if test="${student.courses.size() ne 0}">
                <td>
                    <c:forEach var="course" items="${student.courses}">
                        ${course.title}
                        <br>
                    </c:forEach>
                </td>
            </c:if>
        </tr>
    </c:forEach>
</table>
<hr>
<table border="1">
    <tr>
        <th>ID</th>
        <th>COURSE</th>
        <th>STUDENTS</th>
    </tr>
    <c:forEach var="course" items="${sessionScope.courses}">
        <tr>
            <td>${course.id}</td>
            <td>${course.title}</td>
            <c:if test="${course.students.size() eq 0}">
                <td>
                    没人选
                </td>
            </c:if>
            <c:if test="${course.students.size() ne 0}">
                <td>
                    <c:forEach var="student" items="${course.students}">
                        ${student.name}
                        <br>
                    </c:forEach>
                </td>
            </c:if>
        </tr>
    </c:forEach>
</table>
</body>
</html>
